<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html lang="en">
<head>
</head>

<body class="no-skin">

	<!-- /section:basics/sidebar -->
	<div class="main-content">
		<!-- #section:basics/content.breadcrumbs -->
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try {
					ace.settings.check('breadcrumbs', 'fixed')
				} catch (e) {
				}
			</script>

			<ul class="breadcrumb">
				<li><i class="ace-icon fa fa-home home-icon"></i> <a href="#">管理学生信息</a></li>
			</ul>
			<!-- /.breadcrumb -->

			<!-- #section:basics/content.searchbox -->
			<div class="nav-search" id="nav-search">
				<form class="form-search">
					<span class="input-icon"> <input type="text" placeholder="Search ..."
						class="nav-search-input" id="nav-search-input" autocomplete="off" /> <i
						class="ace-icon fa fa-search nav-search-icon"></i>
					</span>
				</form>
			</div>
			<!-- /.nav-search -->

			<!-- /section:basics/content.searchbox -->
		</div>

		<!-- /section:basics/content.breadcrumbs -->
		<div class="page-content">
			<!-- #section:settings.box -->
			<div class="ace-settings-container" id="ace-settings-container">
				<div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
					<i class="ace-icon fa fa-cog bigger-150"></i>
				</div>

				<div class="ace-settings-box clearfix" id="ace-settings-box">
					<div class="pull-left width-50">
						<!-- #section:settings.skins -->
						<div class="ace-settings-item">
							<div class="pull-left">
								<select id="skin-colorpicker" class="hide">
									<option data-skin="no-skin" value="#438EB9">#438EB9</option>
									<option data-skin="skin-1" value="#222A2D">#222A2D</option>
									<option data-skin="skin-2" value="#C6487E">#C6487E</option>
									<option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
								</select>
							</div>
							<span>&nbsp; Choose Skin</span>
						</div>

						<!-- /section:settings.skins -->

						<!-- #section:settings.navbar -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" /> <label
								class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
						</div>

						<!-- /section:settings.navbar -->

						<!-- #section:settings.sidebar -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" /> <label
								class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
						</div>

						<!-- /section:settings.sidebar -->

						<!-- #section:settings.breadcrumbs -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" /> <label
								class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
						</div>

						<!-- /section:settings.breadcrumbs -->

						<!-- #section:settings.rtl -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" /> <label
								class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
						</div>

						<!-- /section:settings.rtl -->

						<!-- #section:settings.container -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container" /> <label
								class="lbl" for="ace-settings-add-container"> Inside <b>.container</b>
							</label>
						</div>

						<!-- /section:settings.container -->
					</div>
					<!-- /.pull-left -->

					<div class="pull-left width-50">
						<!-- #section:basics/sidebar.options -->
						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover" /> <label
								class="lbl" for="ace-settings-hover"> Submenu on Hover</label>
						</div>

						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact" /> <label
								class="lbl" for="ace-settings-compact"> Compact Sidebar</label>
						</div>

						<div class="ace-settings-item">
							<input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight" /> <label
								class="lbl" for="ace-settings-highlight"> Alt. Active Item</label>
						</div>

						<!-- /section:basics/sidebar.options -->
					</div>
					<!-- /.pull-left -->
				</div>
				<!-- /.ace-settings-box -->
			</div>
			<!-- /.ace-settings-container -->

			<!-- /section:settings.box -->
			<div class="page-content-area">
				<!-- /.page-header -->

				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->
						<div class="row">
							<div class="col-xs-12">
								<c:if test="${not empty message }">
									<script type="text/javascript">
										alert("${message }");
									</script>
								</c:if>
								<button id="addStudent" class="btn btn-primary">
									<span class="ace-icon fa fa-plus align-top bigger-125">&nbsp;&nbsp;<spring:message
											code="page.model.add"></spring:message></span>
								</button>
								<button id="batchAddStudentBtn" class="btn btn-primary">
									<span class="ace-icon fa fa-plus align-top bigger-125">&nbsp;&nbsp;<spring:message
											code="page.batch.uploadfile"></spring:message></span>
								</button>
								<button id="batchdeleteStudentBtn" class="btn btn-primary">
									<span class="ace-icon fa fa-plus align-top bigger-125">&nbsp;&nbsp;<spring:message
											code="user.batch.delete"></spring:message></span>
								</button>
								<a href="deleteAllStudents" class="btn btn-primary"><span
									class="ace-icon fa fa-plus align-top bigger-125">&nbsp;&nbsp;<spring:message
											code="user.delete.all"></spring:message></span></a>
								<table id="sample-table-1" class="table table-striped table-bordered table-hover">
									<thead>

										<tr>

											<th class="center"><label class="position-relative"> <input type="checkbox"
													class="ace" /> <span class="lbl"></span>
											</label></th>

											<th><spring:message code="user.message.id"></spring:message></th>
											<th><spring:message code="user.message.name"></spring:message></th>
											<th><spring:message code="user.message.gender"></spring:message></th>
											<th><spring:message code="user.message.birthday"></spring:message></th>
											<th><spring:message code="user.message.phone"></spring:message></th>
											<th><spring:message code="user.message.email"></spring:message></th>
											<th><spring:message code="user.message.address"></spring:message></th>
											<th><i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i> <spring:message
													code="user.message.operate"></spring:message></th>

										</tr>
									</thead>

									<tbody>
										<c:forEach var="list" items="${student }">
											<tr>
												<td class="center"><label class="position-relative"> <input type="checkbox"
														class="ace" /> <span class="lbl"></span>
												</label></td>
												<td>${list.id }</td>
												<td>${list.name }</td>
												<c:if test="${list.gender == 0 }">
													<td><spring:message code="user.message.man"></spring:message></td>
												</c:if>
												<c:if test="${list.gender == 1 }">
													<td><spring:message code="user.message.woman"></spring:message></td>
												</c:if>
												<td>${list.birthday }</td>
												<td>${list.phone }</td>
												<td>${list.email }</td>
												<td>${list.address }</td>
												<td>
													<div class="hidden-sm hidden-xs btn-group">
														<a title="修改" class="btn btn-primary btn-xs update-user"> <i class="ace-icon fa fa-pencil bigger-120"></i>
														</a> <a title="删除" class="btn btn-primary btn-xs delete-user"> 
														<i class="ace-icon fa fa-trash-o bigger-120"></i>
														</a>
														<a title="管理科目学生" class="btn btn-primary btn-xs manage-subject-student-btn">
														<i class="ace-icon fa fa-users"></i>
														</a>
													</div>

													<div class="hidden-md hidden-lg">
														<div class="inline position-relative">
															<button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
																data-position="auto">
																<i class="ace-icon fa fa-cog icon-only bigger-110"></i>
															</button>

															<ul
																class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">

																<li><a href="#" class="tooltip-success" data-rel="tooltip" title="Edit"> <span
																		class="green"> <i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
																	</span>
																</a></li>

																<li><a href="#" onclick="if(confirm('确定删除?')==false)return false;"
																	class="tooltip-error" data-rel="tooltip" title="Delete"> <span class="red">
																			<i class="ace-icon fa fa-trash-o bigger-120"></i>
																	</span>
																</a></li>
															</ul>
														</div>
													</div>
												</td>
											</tr>
										</c:forEach>

									</tbody>
								</table>
							</div>
							<!-- /.span -->
						</div>
						<!-- /.row -->
						<div class="modal fade" id="uploadFileModal" tabindex="-1" role="dialog"
							aria-labelledby="uploadFileModalLabel" aria-hidden="true">
							<div class="modal-dialog">
								<div class="modal-content">
									<div class="modal-header">
										<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
										<h4 class="modal-title" id="uploadFileModalLabel">
											<spring:message code="page.model.uploadfile"></spring:message>
										</h4>
									</div>
									<div class="modal-body">
										<input id="uploadFile" name="uploadFile" type="file" />
									</div>
									<div class="modal-footer">
										<button type="button" class="btn btn-default" data-dismiss="modal">
											<spring:message code="page.model.close"></spring:message>
										</button>
										<button id="subjectStudentSaveBtn" type="button" class="btn btn-primary">
											<spring:message code="page.model.save"></spring:message>
										</button>
									</div>
								</div>
							</div>
						</div>

						<!-- PAGE CONTENT ENDS -->
					</div>
					<!-- /.col -->
				</div>
				<!-- /.row -->
			</div>
			<!-- /.page-content-area -->
		</div>
		<!-- /.page-content -->
	</div>
	<!-- /.main-content -->

	<div class="modal fade" id="addUserModal" tabindex="-1" role="dialog"
		aria-labelledby="addUserModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="addUserModalLabel">
						<spring:message code="model.title.add"></spring:message>
					</h4>
				</div>
				<div class="modal-body">
					<form id="addUserForm" method="post">

						<p>
							<label>*<spring:message code="user.message.id"></spring:message>：
							</label><input type="text" name="id" />
						</p>
						<p>
							<label>*<spring:message code="user.message.name"></spring:message>：
							</label><input type="text" name="name" />
						</p>
						<p>
							<label>*<spring:message code="user.message.gender"></spring:message>：
							</label> <input type="radio" name="gender" value="0" />
							<spring:message code="user.message.man"></spring:message>
							<input type="radio" name="gender" value="1" />
							<spring:message code="user.message.woman"></spring:message>
						</p>
						<p>
							<label>*<spring:message code="user.message.birthday"></spring:message>：
							</label><input type="text" name="birthday" />
						</p>
						<p>
							<label><spring:message code="user.message.email"></spring:message>：</label><input type="text"
								name="email" />
						</p>
						<p>
							<label><spring:message code="user.message.phone"></spring:message>：</label><input type="text"
								name="phone" />
						</p>
						<p>
							<label><spring:message code="user.message.address"></spring:message>：</label><input
								type="text" name="address" />
						</p>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">
						<spring:message code="page.model.close"></spring:message>
					</button>
					<button type="button" class="btn btn-primary" id="addUserSaveBtn">
						<spring:message code="page.model.add"></spring:message>
					</button>
				</div>
			</div>
		</div>
	</div>

	<div class="modal fade" id="updateUserModal" tabindex="-1" role="dialog"
		aria-labelledby="updateUserModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="updateUserModalLabel">
						<spring:message code="model.title.update"></spring:message>
					</h4>
				</div>
				<div class="modal-body">
					<form id="updateUserForm" method="post">

						<p>
							<label><spring:message code="user.message.id"></spring:message>：</label><input type="text"
								name="id" readonly='readonly' />
						</p>
						<p>
							<label>*<spring:message code="user.message.name"></spring:message>：
							</label><input type="text" name="name" />
						</p>
						<p>
							<label>*<spring:message code="user.message.gender"></spring:message>：
							</label> <input type="radio" name="gender" value="0" />
							<spring:message code="user.message.man"></spring:message>
							<input type="radio" name="gender" value="1" />
							<spring:message code="user.message.woman"></spring:message>
						</p>
						<p>
							<label>*<spring:message code="user.message.birthday"></spring:message>：
							</label><input type="text" name="birthday" />
						</p>
						<p>
							<label><spring:message code="user.message.email"></spring:message>：</label><input type="text"
								name="email" />
						</p>
						<p>
							<label><spring:message code="user.message.phone"></spring:message>：</label><input type="text"
								name="phone" />
						</p>
						<p>
							<label><spring:message code="user.message.address"></spring:message>：</label><input
								type="text" name="address" />
						</p>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">
						<spring:message code="page.model.close"></spring:message>
					</button>
					<button type="button" class="btn btn-primary" id="updateUserSaveBtn">
						<spring:message code="page.model.add"></spring:message>
					</button>
				</div>
			</div>
		</div>
	</div>
	<div class="modal fade" id="subjectStudentModal" tabindex="-1" role="dialog"
		aria-labelledby="subjectSubjectModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="subjectSubjectModalLabel">
						管理学生科目:<label id="modalSubjectName"></label>
					</h4>
				</div>
				<div class="modal-body">
					<input type="hidden" id="userId" />
					<div id="subjectStudentContent" class="control-group"></div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" id="studentSubjectSaveBtn">保存</button>
				</div>
			</div>
		</div>
	</div>

	<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse"> <i
		class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
	</a>
	<!-- /.main-container -->
	<div style="text-align: center">
		<a href="pageLanguage?localeType=zh_CN"><spring:message code="page.language.chinese"></spring:message></a>
		&nbsp;<a href="pageLanguage?localeType=en"><spring:message code="page.language.english"></spring:message></a>
	</div>
	<!-- basic scripts -->

	<!--[if !IE]> -->
	<script type="text/javascript">
		window.jQuery
				|| document
						.write("<script src='${pageContext.request.contextPath}/static/assets/js/jquery.min.js'>"
								+ "<"+"/script>");
	</script>

	<!-- <![endif]-->

	<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='${pageContext.request.contextPath}/static/assets/js/jquery1x.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
	<script type="text/javascript">		
		if ('ontouchstart' in document.documentElement)
			document
					.write("<script src='${pageContext.request.contextPath}/static/assets/js/jquery.mobile.custom.min.js'>"
							+ "<"+"/script>");
	</script>
	<script src="${pageContext.request.contextPath}/static/assets/js/bootstrap.min.js"></script>

	<!-- page specific plugin scripts -->
	<script src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.min.js"></script>
	<script src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.bootstrap.js"></script>

	<!-- ace scripts -->
	<script src="${pageContext.request.contextPath}/static/assets/js/ace-elements.min.js"></script>

	<!-- inline scripts related to this page -->
	<script type="text/javascript">
		jQuery(function($) {
			var oTable1 = $('#sample-table-2')
			//.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
			.dataTable({
				bAutoWidth : false,
				"aoColumns" : [ {
					"bSortable" : false
				}, null, null, null, null, null, {
					"bSortable" : false
				} ],
				"aaSorting" : [],

			//,
			//"sScrollY": "200px",
			//"bPaginate": false,

			//"sScrollX": "100%",
			//"sScrollXInner": "120%",
			//"bScrollCollapse": true,
			//Note: if you are applying horizontal scrolling (sScrollX) on a ".table-bordered"
			//you may want to wrap the table inside a "div.dataTables_borderWrap" element

			//"iDisplayLength": 50
			});
			/**
			var tableTools = new $.fn.dataTable.TableTools( oTable1, {
				"sSwfPath": "../../copy_csv_xls_pdf.swf",
			    "buttons": [
			        "copy",
			        "csv",
			        "xls",
					"pdf",
			        "print"
			    ]
			} );
			$( tableTools.fnContainer() ).insertBefore('#sample-table-2');
			 */

			$(document).on(
					'click',
					'th input:checkbox',
					function() {
						var that = this;
						$(this).closest('table').find(
								'tr > td:first-child input:checkbox').each(
								function() {
									this.checked = that.checked;
									$(this).closest('tr').toggleClass(
											'selected');
								});
					});

			$('[data-rel="tooltip"]').tooltip({
				placement : tooltip_placement
			});
			function tooltip_placement(context, source) {
				var $source = $(source);
				var $parent = $source.closest('table')
				var off1 = $parent.offset();
				var w1 = $parent.width();

				var off2 = $source.offset();
				//var w2 = $source.width();

				if (parseInt(off2.left) < parseInt(off1.left)
						+ parseInt(w1 / 2))
					return 'right';
				return 'left';
			}

		})
	</script>

	<!-- the following scripts are used in demo only for onpage help and you don't need them -->

	<script type="text/javascript">
		ace.vars['base'] = '..';
	</script>
	<script src="${pageContext.request.contextPath}/static/assets/js/ace/elements.onpage-help.js"></script>
	<script src="${pageContext.request.contextPath}/static/assets/js/ace/ace.onpage-help.js"></script>
	<script src="${pageContext.request.contextPath}/static/docs/assets/js/rainbow.js"></script>
	<script src="${pageContext.request.contextPath}/static/docs/assets/js/language/generic.js"></script>
	<script src="${pageContext.request.contextPath}/static/docs/assets/js/language/html.js"></script>
	<%-- <script
		src="${pageContext.request.contextPath}/docs/assets/js/language/css.js"></script>
	<script
		src="${pageContext.request.contextPath}/docs/assets/js/language/javascript.js"></script> --%>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/static/lib/ajaxfileupload.js"></script>
	<script type="text/javascript">
		$('#batchAddStudentBtn').click(function() {
			$("#uploadFileModal").modal('show');
		});

		$('#uploadFile').ace_file_input({
			style : 'well',
			btn_choose : 'Drop files here or click to choose',
			btn_change : null,
			no_icon : 'ace-icon fa fa-cloud-upload',
			droppable : true,
			thumbnail : 'small',
			preview_error : function(filename, error_code) {
			}
		}).on('change', function(filename, error_code) {

		});

		$('#subjectStudentSaveBtn').on('click', function() {
			$.ajaxFileUpload({
				url : "${pageContext.request.contextPath}/teacher/uploadFile",
				secureuri : false,
				fileElementId : "uploadFile",
				dataType : 'json',
				complete : function(data) {
					
				},
				success : function(data, status) {
					if (data.success) {
						alert('上传成功');
						window.location.reload();
					} else {
						alert(data.messageMap.message);
					}
				},
				error : function(data, status, e) {
					alert(e);
				}
			});
		});
	</script>
	<script type="text/javascript">
		$('#addStudent').click(function() {
			$('#addUserModal').modal('show');
		});
		$('#addUserSaveBtn')
				.click(
						function() {
							var userId = $('#addUserForm input[name="id"]')
									.val();
							var userName = $('#addUserForm input[name="name"]')
									.val();
							var gender = $(
									'#addUserForm input[name="gender"]:radio:checked')
									.val();
							var birthday = $(
									'#addUserForm input[name="birthday"]')
									.val();
							var phone = $('#addUserForm input[name="phone"]')
									.val();
							var address = $(
									'#addUserForm input[name="address"]').val();
							var email = $('#addUserForm input[name="email"]')
									.val();
							$
									.ajax({
										type : 'POST',
										url : '${pageContext.request.contextPath}/teacher/addStudent',
										data : {
											id : userId,
											name : userName,
											gender : gender,
											birthday : birthday,
											phone : phone,
											address : address,
											email : email
										},
										dataType : "json",
										success : function(data) {
											if (data.success) {
												alert('添加成功');
												window.location.reload();
											} else {
												var messageMap = data.messageMap;
												alert('添加失败!');
												for ( var key in messageMap) {
													var value = messageMap[key];
													$(
															'#addUserForm input[name="'
																	+ key
																	+ '"]')
															.after(
																	'<label style="color:red">'
																			+ value
																			+ '</label>');
												}
											}
										}
									});
						});
	</script>
	<script type="text/javascript">
		$('.update-user')
				.click(
						function() {
							var userId = $(this).parent().parent().siblings()
									.eq(1).text();
							$
									.ajax({
										type : 'POST',
										url : '${pageContext.request.contextPath}/teacher/getExamUserById',
										data : {
											userId : userId
										},
										dataType : "json",
										success : function(data) {
											$(
													'#updateUserForm input[name="id"]')
													.val(data.id);
											$(
													'#updateUserForm input[name="name"]')
													.val(data.name);
											if (data.gender == 0) {
												($('#updateUserForm input[name="gender"]'))[0].checked = true;
											} else {
												($('#updateUserForm input[name="gender"]'))[1].checked = true;
											}
											$(
													'#updateUserForm input[name="birthday"]')
													.val(data.birthday);
											$(
													'#updateUserForm input[name="phone"]')
													.val(data.phone);
											$(
													'#updateUserForm input[name="address"]')
													.val(data.address);
											$(
													'#updateUserForm input[name="email"]')
													.val(data.email);
										}
									});
							$('#updateUserModal').modal('show');
						});
		$('#updateUserSaveBtn')
				.click(
						function() {
							var userId = $('#updateUserForm input[name="id"]')
									.val();
							var userName = $(
									'#updateUserForm input[name="name"]').val();
							var gender = $(
									'#updateUserForm input[name="gender"]:radio:checked')
									.val();
							var birthday = $(
									'#updateUserForm input[name="birthday"]')
									.val();
							var phone = $('#updateUserForm input[name="phone"]')
									.val();
							var address = $(
									'#updateUserForm input[name="address"]')
									.val();
							var email = $('#updateUserForm input[name="email"]')
									.val();
							$
									.ajax({
										type : 'POST',
										url : '${pageContext.request.contextPath}/teacher/updateStudent',
										data : {
											id : userId,
											name : userName,
											gender : gender,
											birthday : birthday,
											phone : phone,
											address : address,
											email : email
										},
										dataType : "json",
										success : function(data) {
											if (data.success) {
												alert('修改成功');
												window.location.reload();
											} else {
												var messageMap = data.messageMap;
												alert('修改失败!');
												for ( var key in messageMap) {
													var value = messageMap[key];
													$(
															'#addUserForm input[name="'
																	+ key
																	+ '"]')
															.after(
																	'<label class="jsr303-message-label">'
																			+ value
																			+ '</label>');
												}
											}
										}
									});
						});
	</script>
	<script type="text/javascript">
		$('.delete-user')
				.click(
						function() {
							userId = $(this).parent().parent().siblings().eq(1)
									.text();
							if (confirm('确定删除?') == true) {
								$
										.ajax({
											type : 'POST',
											url : '${pageContext.request.contextPath}/teacher/deleteStudent',
											data : {
												userId : userId
											},
											success : function(data) {
												if (data == "success") {
													alert("删除成功");
													window.location.reload();
												} else {
													alert("删除失败");
												}
											}
										});
							}
						});
		$('#batchdeleteStudentBtn')
				.click(
						function() {
							var checkArray = $('#sample-table-1 .ace');
							var userId = new Array();
							$("#sample-table-1 input:checkbox")[1];
							for (var i = 1; i < checkArray.length; i++) {
								if (checkArray.eq(i).is(':checked')) {
									userId[userId.length] = $(
											'#sample-table-1 tbody tr').eq(
											i - 1).find('td').eq(1).text();
								}
							}
							if (userId.length > 0) {
								$
										.ajax({
											type : 'POST',
											url : '${pageContext.request.contextPath}/teacher/batchDeleteStudents',
											data : {
												userId : userId
											},
											success : function(data) {
												if (data == "success") {
													alert('批量删除成功');
													window.location.reload();
												} else {
													alert('批量删除失败');
												}
											}
										});
							}
						});
	</script>
	<script type="text/javascript">
		var userId = 0;
		$('.manage-subject-student-btn').click(function(){
			userId = $(this).parent().parent().siblings().eq(1).text();
			$.ajax({
				type: "POST",
				url:  "${pageContext.request.contextPath}/teacher/getAllSubject",
				data: {
					userId: userId
					},
				dataType: "json",
				success: function(data){
					var htmlString = '';
					var selectedSubject = data.selectedSubject;
					for(var i = 0; i < data.allSubject.length; i++){
						var subject = data.allSubject[i];
						var checked = '';
						for(var j = 0; j < selectedSubject.length; j++) {
							if(selectedSubject[j] == subject.id){
								checked = 'checked="true"';
							}
						}
 						htmlString += '<div class="checkbox">';
						htmlString += '		<label>';
						htmlString += '			<input name="subjectStudents" class="ace ace-checkbox-2" type="checkbox" value="'
							+ subject.id +'"'+ checked +' />';
						htmlString += '			<span class="lbl">' + subject.name + '</sapn>';		
						htmlString += '		</label>';
						htmlString += '</div>';
					}
					$('#subjectStudentContent').html(htmlString);
					/* $('#subjectStudentModal #userId').val(userId); */
					}
			});
			$('#modalSubjectName').text($(this).parents('td').siblings('td').eq(1).text());
			$('#subjectStudentModal').modal('show');
		});

		$('#studentSubjectSaveBtn').click( function(){
				var studentSubjects = [];
				for(var i = 0; i < $('input[name="subjectStudents"]:checked').length; i++){
					studentSubjects[i] = $($('input[name="subjectStudents"]:checked')[i]).val();
				}
				$.ajax({
					type: "POST",
					url: "${pageContext.request.contextPath}/teacher/saveStudentSubjects",
					data: {
						studentSubjects: studentSubjects,
						userId: userId
					},
					success: function(data){
						if(data == "success"){
							alert('成功');
							window.location.reload();
						} else {
							alert('失败');
						}
						}
					});
			});
	</script>
</body>
</html>